home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / PartMaker 4.4 / PartMaker Documents / SamplePart (C)• / SamplePart (C)•.rsrc / dFRK_5023 < prev    next >
Encoding:
Text File  |  1995-12-14  |  35.5 KB  |  1,333 lines

  1. /*
  2.     File:        SamplePartUtils.c
  3.  
  4.     Contains:    SamplePart utility functions & classes
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1994,95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. // -- Compiler/Preprocessor Notification -- 
  12.  
  13. #ifndef _COMPILERDEFS_
  14. #include "CompDefs.h"
  15. #endif
  16.  
  17. // -- OpenDoc Utilities --
  18.  
  19. #ifndef _EXCEPT_
  20. // Exceptions define several important macros (ie. CHECKENV)
  21. // which are used in the SOM method dispatch glue. If Except.h
  22. // is not included early enough, exceptions may not be thrown
  23. // correctly when returning from a SOM method with the "ev" parameter set.
  24. #include <Except.h>
  25. #endif
  26.  
  27. // --- SamplePart Includes ---
  28.  
  29. #ifndef _SAMPLEPARTUTILS_
  30. #include "SamplePartUtils.h"
  31. #endif
  32.  
  33. #ifndef _SAMPLEPARTDEF_
  34. #include "SamplePartDef.h"
  35. #endif
  36.  
  37. // --- OpenDoc Includes ---
  38.  
  39. #ifndef _ODTYPES_
  40. #include <ODTypes.h>
  41. #endif
  42.  
  43. #ifndef SOM_ODPart_h
  44. #include <Part.h>
  45. #endif
  46.  
  47. #ifndef SOM_Module_OpenDoc_StdProps_defined
  48. #include <StdProps.h>
  49. #endif
  50.  
  51. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  52. #include <StdTypes.h>
  53. #endif
  54.  
  55. #ifndef SOM_ODFrame_h
  56. #include <Frame.h>
  57. #endif
  58.  
  59. #ifndef SOM_ODFrameFacetIterator_h
  60. #include <FrFaItr.h>
  61. #endif
  62.  
  63. #ifndef SOM_ODDraft_h
  64. #include <Draft.h>
  65. #endif
  66.  
  67. #ifndef SOM_ODStorageUnit_h
  68. #include <StorageU.h>
  69. #endif
  70.  
  71. #ifndef SOM_ODStorageUnitView_h
  72. #include <SUView.h>
  73. #endif
  74.  
  75. #ifndef SOM_ODNameSpaceManager_h
  76. #include <NmSpcMg.h>
  77. #endif
  78.  
  79. #ifndef SOM_ODValueNameSpace_h
  80. #include <ValueNS.h>
  81. #endif
  82.  
  83. #ifndef SOM_ODContainer_h
  84. #include <ODCtr.h>
  85. #endif
  86.  
  87. #ifndef SOM_ODDocument_h
  88. #include <Document.h>
  89. #endif
  90.  
  91. #ifndef SOM_ODWindowState_h
  92. #include <WinStat.h>
  93. #endif
  94.  
  95. // --- OpenDoc Public Utilities ---
  96.  
  97. #ifndef _MEMMGR_
  98. //#include <MemMgr.h>
  99. #endif
  100.  
  101. #ifndef _STDTYPIO_
  102. #include "StdTypIO.h"
  103. #endif
  104.  
  105. #ifndef _ITEXT_
  106. #include <IText.h>
  107. #endif
  108.  
  109. #ifndef _ISOSTR_
  110. #include <ISOStr.h>
  111. #endif
  112.  
  113. #ifndef _PASCLSTR_
  114. #include <PasclStr.h>
  115. #endif
  116.  
  117. #ifndef _USERSRCM_
  118. #include <UseRsrcM.h>
  119. #endif
  120.  
  121. #ifndef _ODUTILS_
  122. #include <ODUtils.h>
  123. #endif
  124.  
  125. #ifndef _ODMEMORY_
  126. #include <ODMemory.h>
  127. #endif
  128.  
  129. // --- Macintosh Includes ---
  130.  
  131. #ifndef __RESOURCES__
  132. #include <Resources.h>
  133. #endif
  134.  
  135. #ifndef __GXMATH__
  136. #include <GXMath.h>
  137. #endif
  138.  
  139. #ifndef __SCRIPT__
  140. #include <Script.h>
  141. #endif
  142.  
  143. #ifndef __TEXTUTILS__
  144. #include <TextUtils.h>
  145. #endif
  146.  
  147. #pragma segment SamplePartUtilities
  148.  
  149. //====================================================================
  150. // Utility Functions
  151. //====================================================================
  152.  
  153. //==============================================================================
  154. #pragma mark    • Functions •
  155. //==============================================================================
  156.  
  157. //--------------------------------------------------------------------
  158. // NamesAreEquivalent
  159. //--------------------------------------------------------------------
  160.  
  161. ODBoolean NamesAreEquivalent(Environment* ev, ODIText* fileName,
  162.                                         ODIText* partName)
  163. {
  164.     Str255 fileStr;
  165.     Str255 partStr;
  166.     
  167.     // If the strings are in different languages, we're done.
  168.     if ( (GetITextScriptCode(fileName) != GetITextScriptCode(partName)) ||
  169.             GetITextLangCode(fileName) != GetITextLangCode(partName) )
  170.         return kODFalse;
  171.     
  172.     GetITextPString(fileName, fileStr);
  173.     GetITextPString(partName, partStr);
  174.  
  175.     // If the string lengths are different, we're done.
  176.     if ( fileStr[0] != partStr[0] )
  177.         return kODFalse;
  178.  
  179.     // Return the Toolbox string equivalence test.
  180.     return EqualString(fileStr,partStr,kODTrue,kODTrue);
  181. }
  182.  
  183. //------------------------------------------------------------------------------
  184. // ValueNameSpaceGetODName (from NmSpcUtl.cpp)
  185. // Method included here because source file will not compile using C compiler.
  186. //------------------------------------------------------------------------------
  187.  
  188. ODBoolean ValueNameSpaceGetODName(ODValueNameSpace* ns, 
  189.                                  Environment* ev,
  190.                                    ODISOStr key,
  191.                                    ODName** value)
  192. {
  193.     ODByteArray ba;
  194.     ODULong textLen = 0;
  195.     StringPtr thePString;
  196.     
  197.     if (ODValueNameSpace_GetEntry(ns, ev, key, &ba))
  198.     {
  199.         ODTradITextData* theIName = (ODTradITextData*)ODNewPtrClear(ba._length, kDefaultHeapID);
  200.         ODBlockMove(ba._buffer, theIName, ba._length);
  201.         ODDisposePtr( ba._buffer );
  202.         textLen = ba._length - sizeof(ODTradITextDataHeader);
  203.         thePString = (StringPtr)ODNewPtrClear(textLen+1, kODNULL);
  204.         thePString[0] = textLen;
  205.         ODBlockMove((ODPtr)theIName->theText, (ODPtr)&thePString[1], textLen );
  206.         *value = CreateITextPString(theIName->theScriptCode, 
  207.                              theIName->theLangCode, 
  208.                              thePString);
  209.         ODDisposePtr( theIName );
  210.         ODDisposePtr( thePString );
  211.         return kODTrue;
  212.     }
  213.     else
  214.     {
  215.         *value = kODNULL;
  216.         return kODFalse;
  217.     }
  218. }
  219.  
  220. //------------------------------------------------------------------------------
  221. // GetUserCatFromCat (from BndNSUtl.cpp)
  222. // Method included here because source file will not compile using C compiler.
  223. //------------------------------------------------------------------------------
  224.  
  225. ODBoolean GetUserCatFromCat(ODNameSpaceManager* theNmSpcMgr, 
  226.                                     ODType category, ODIText** name)
  227. {
  228.     ODValueNameSpace*    userStringNameSpace;
  229.     ODBoolean            result = kODFalse;
  230.     Environment*        ev = somGetGlobalEnvironment();
  231.  
  232.     // look it up in the spaceName namespace
  233.     userStringNameSpace = (ODValueNameSpace*)
  234.         ODNameSpaceManager_HasNameSpace(theNmSpcMgr, ev, kODCategoryUserString);
  235.  
  236.     if (userStringNameSpace)
  237.         result = ValueNameSpaceGetODName(userStringNameSpace, ev,
  238.                                                 category, name);
  239.     return result ;
  240. }
  241.  
  242. //--------------------------------------------------------------------
  243. // GetPartName
  244. //--------------------------------------------------------------------
  245.  
  246. ODIText* GetPartName(Environment* ev, ODPart* part, ODType category)
  247. {
  248.     ODDraft* draft = kODNULL;
  249.     ODPart* rootPart = kODNULL;
  250.     ODIText* partName = kODNULL;
  251.     ODContainer* container = kODNULL;
  252.     ODDocument* document = kODNULL;
  253.     ODIText* categoryName;
  254.     ODNameSpaceManager* nsMgr;
  255.     ODSession* session;
  256.     ODStorageUnit*    su;
  257.     
  258.     if (part != kODNULL)
  259.     {
  260.  
  261.         // Get the root part of the document.
  262.         draft = ODGetDraftFromPart(ev,part);
  263.         su = ODDraft_AcquireDraftProperties( draft, ev );
  264.         rootPart = ODDraft_AcquirePart(draft, ev, ODGetStrongSURefProp(ev, su, kODPropRootPartSU, kODStrongStorageUnitRef));
  265.         ODReleaseObject(ev, su);
  266.         
  267.         // Get the part name.
  268.         // If we can't get a valid name for the part, we generate one using
  269.         // the user visible category name of the part's category.
  270.         partName = ODGetITextProp(ev, ODPart_GetStorageUnit(part, ev), 
  271.                                              kODPropName, kODMacIText, kODNULL);
  272.         
  273.         if ( (partName == kODNULL) || (GetITextStringLength(partName) == 0) )
  274.         {
  275.             session = ODGetSessionFromPart(ev,part);
  276.             nsMgr = ODSession_GetNameSpaceManager(session, ev);
  277.             
  278.             // Get the category string from the category name space.
  279.             if ( GetUserCatFromCat(nsMgr, category, &categoryName) )
  280.             {
  281.                 // If we successfully retrieved the category user string, return it.
  282.                 // (This code transfers the ODIText object to the partName tempobj)
  283.                 DisposeIText(partName);
  284.                 partName = categoryName;
  285.             }
  286.             else
  287.             {
  288. #if ODDebug
  289.                 // This should never happen. Check NMAP for errors.
  290.                 DebugStr("\pCategory NMAP bad, or nmap cache file corrupted.");
  291. #else
  292.                 THROW(kODErrInvalidNSType);
  293. #endif
  294.             }
  295.         }
  296.         
  297.         ODReleaseObject(ev, rootPart);
  298.     }
  299.     
  300.     return partName;
  301. }
  302.  
  303. //--------------------------------------------------------------------
  304. // GetEditorScriptLanguage
  305. //--------------------------------------------------------------------
  306.  
  307. void GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
  308.                                         ODLangCode* language)
  309. {
  310.     OSErr    error = noErr;
  311.     long    region;
  312.     ODSLong rfRef;
  313.  
  314.     rfRef = BeginUsingLibraryResources();
  315.     {
  316.         Handle versHdl = GetResource('vers', 1);
  317.         
  318.         // Get the region code of the editor, otherwise use the
  319.         // region code the of the primary system script.
  320.         
  321.         if ( versHdl )
  322.         {
  323.             region = (long)(*(VersRecHndl)versHdl)->countryCode;
  324.             ReleaseResource(versHdl);
  325.         }
  326.         else
  327.         {
  328.             region = GetScriptManagerVariable(smRegionCode);
  329.         }
  330.         
  331.         // Spanish & Japanese are not actually supported by the editor.
  332.         // They are provided as examples of how to add recognition of
  333.         // additional regions (see Script.h for region codes).
  334.         
  335.         switch ((short)region) {
  336.             case verUS:
  337.                 *script = smRoman;
  338.                 *language = langEnglish;
  339.                 break;
  340.             case verSpain:
  341.                 *script = smRoman;
  342.                 *language = langSpanish;
  343.                 break;
  344.             case verJapan:
  345.                 *script = smJapanese;
  346.                 *language = langJapanese;
  347.                 break;
  348.             default:
  349.                 *script = smRoman;
  350.                 *language = langEnglish;
  351.         }                
  352.     }
  353.     EndUsingLibraryResources(rfRef);
  354. }
  355.  
  356. //--------------------------------------------------------------------
  357. // FixedToIntRect
  358. //--------------------------------------------------------------------
  359.  
  360. void FixedToIntRect(ODRect* fixedRect, Rect* intRect)
  361. {
  362.     intRect->top    = FixedToInt(fixedRect->top);
  363.     intRect->left    = FixedToInt(fixedRect->left);
  364.     intRect->bottom    = FixedToInt(fixedRect->bottom);
  365.     intRect->right    = FixedToInt(fixedRect->right);
  366. }
  367.  
  368. //--------------------------------------------------------------------
  369. // IntToFixedRect
  370. //--------------------------------------------------------------------
  371.  
  372. void IntToFixedRect(Rect* intRect, ODRect* fixedRect)
  373. {
  374.     fixedRect->left        = ff(intRect->left);
  375.     fixedRect->top        = ff(intRect->top);
  376.     fixedRect->right    = ff(intRect->right);
  377.     fixedRect->bottom    = ff(intRect->bottom);
  378. }
  379.  
  380. //--------------------------------------------------------------------
  381. // LoadThumbnail
  382. //--------------------------------------------------------------------
  383.  
  384. void LoadThumbnail(Environment* ev, Handle* thumbnail)
  385. {
  386.     ODSLong rfRef;
  387.  
  388.     if ( *thumbnail ) return;
  389.     
  390.     rfRef = BeginUsingLibraryResources();
  391.     {
  392.         *thumbnail = (Handle) GetPicture(kThumbnailPicture);
  393.     }
  394.     EndUsingLibraryResources(rfRef);
  395. }
  396.  
  397. //--------------------------------------------------------------------
  398. // TilePartWindow
  399. //--------------------------------------------------------------------
  400.  
  401. Rect TilePartWindow(Environment* ev, Rect* facetBounds, Rect* partWindowBounds)
  402. {
  403.     const short    kWindowTilingConst    = 20;
  404.     const short kLeftToRight        = 0;
  405.     const short kRightToLeft        = -1;
  406.     
  407.     short direction;
  408.     
  409.     // Get the direction for the primary script system running on this machine.
  410.     // (Right-to-Left or Left-to-Right)
  411.     direction = GetSysDirection();
  412.     
  413.     // The part window should be tiled from the topLeft corner of the 
  414.     // active facet who's frame is being opened.
  415.     if ( direction == kLeftToRight )
  416.     {
  417.         // Position the window rect at the top/left corner of the facet.
  418.         OffsetRect(partWindowBounds, facetBounds->left, facetBounds->top);
  419.         // Now tile the window rect down and to the right.
  420.         OffsetRect(partWindowBounds, kWindowTilingConst, kWindowTilingConst);
  421.     }
  422.     // The part window should be tiled from the topRight corner of the 
  423.     // active facet who's frame is being opened.
  424.     else if ( direction == kRightToLeft )
  425.     {
  426.         // Position the window rect at the top/right corner of the facet.
  427.         OffsetRect(partWindowBounds, (partWindowBounds->right - facetBounds->right),
  428.                     facetBounds->top);
  429.         // Now tile the window rect down and to the left.
  430.         OffsetRect(partWindowBounds, -kWindowTilingConst, kWindowTilingConst);
  431.     }
  432.     
  433.     return *partWindowBounds;
  434. }
  435.  
  436. //--------------------------------------------------------------------
  437. // CountFacets
  438. //--------------------------------------------------------------------
  439.  
  440. ODUShort CountFramesFacets(Environment* ev, ODFrame* frame)
  441. {
  442.     ODUShort                facetCount = 0;
  443.     ODFacet*                facet;
  444.     ODFrameFacetIterator*    ffiter;
  445.     
  446.     ODVolatile(ffiter);
  447.     
  448.     TRY
  449.         ffiter = ODFrame_CreateFacetIterator(frame, ev);
  450.         CHECK_ENV(ev);
  451.         
  452.         facet = ODFrameFacetIterator_First(ffiter, ev);
  453.         CHECK_ENV(ev);
  454.         
  455.         while ( ODFrameFacetIterator_IsNotComplete(ffiter, ev) )
  456.         {
  457.             CHECK_ENV(ev);
  458.             
  459.             facetCount++;
  460.             
  461.             facet = ODFrameFacetIterator_Next(ffiter, ev);
  462.             CHECK_ENV(ev);
  463.         }
  464.         ODDeleteObject_C(ffiter);
  465.         
  466.     CATCH_ALL
  467.         ODDeleteObject_C(ffiter);
  468.     ENDTRY
  469.     
  470.     return facetCount;
  471. }
  472.  
  473. //------------------------------------------------------------------------------
  474. // Replacements for overloaded functions from ODUtils.cpp
  475. //------------------------------------------------------------------------------
  476.  
  477. ODDraft* ODGetDraftFromPart( Environment *ev, ODPart *p )
  478. {
  479.     return p ?ODStorageUnit_GetDraft(ODPart_GetStorageUnit(p,ev), ev) :kODNULL;
  480. }
  481.  
  482. ODDraft* ODGetDraftFromSU( Environment *ev, ODStorageUnit *su )
  483. {
  484.     return su ?ODStorageUnit_GetDraft(su, ev) :kODNULL;
  485. }
  486.  
  487. ODSession* ODGetSessionFromPart( Environment *ev, ODPart *p )
  488. {
  489.     return p ?ODStorageUnit_GetSession(ODPart_GetStorageUnit(p,ev), ev) :kODNULL;
  490. }
  491.  
  492. //----------------------------------------------------------------------------------------
  493. // StorageUnitGetValue_C
  494. //
  495. // copied from OpenDoc's StorUtil.cpp.
  496. //----------------------------------------------------------------------------------------
  497. ODULong    StorageUnitGetValue_C(ODStorageUnit* su,
  498.                             Environment* ev,
  499.                             ODULong    size,
  500.                             ODPtr buffer)
  501. {
  502.     ODByteArray    ba;    
  503.     ODULong bytesRead = ODStorageUnit_GetValue(su, ev, size, &ba);
  504.     BlockMove(ba._buffer, buffer, bytesRead);
  505.     ODDisposePtr((Ptr)ba._buffer);
  506.  
  507.     return bytesRead;
  508. }
  509.  
  510. //----------------------------------------------------------------------------------------
  511. // CStorageUnitSetValue_C
  512. //----------------------------------------------------------------------------------------
  513. void StorageUnitSetValue_C(ODStorageUnit* su,
  514.                             Environment* ev,
  515.                             ODULong    size,
  516.                             const void *buffer)
  517. {
  518.     ODByteArray ba;
  519.     ba._length = size;
  520.     ba._maximum = size;
  521.     ba._buffer = (octet*) buffer;
  522.     ODStorageUnit_SetValue(su, ev, &ba);
  523. }
  524.  
  525. //==============================================================================
  526. // CopyAndRelease // similar to 0
  527. //==============================================================================
  528.  
  529. ODShape* CopyAndRelease( Environment *ev, ODShape *s )
  530. {
  531.     ODShape* tempS = kODNULL;
  532.     ODShape *copy = kODNULL;
  533.     
  534.     if( ODShape_GetRefCount(s, ev) == 1 )
  535.         return s;
  536.     tempS = s;        // Ensures that s gets released
  537.     copy = ODShape_Copy(s, ev);
  538.     ODReleaseObject(ev, tempS );
  539.     
  540.     return copy;
  541. }
  542.  
  543. //==============================================================================
  544. #pragma mark    • CLinkedList •
  545. //==============================================================================
  546.  
  547. //====================================================================
  548. // CLinkedList
  549. //====================================================================
  550.  
  551. CLinkedList CLinkedList_Create()
  552. {
  553.     CLinkedList list;
  554.     
  555.     list = (CLinkedList) ODNewPtrClear(sizeof(CLink), kODNULL);
  556.     
  557.     if ( list != kODNULL )
  558.     {
  559.         list->content = kODNULL;
  560.         list->prev = list;
  561.         list->next = list;
  562.     }
  563.     
  564.     return list;
  565. }
  566.  
  567.  
  568. void CLinkedList_Delete(CLinkedList list)
  569. {
  570.     if (list )
  571.     {
  572.         // Delete all links:
  573.         while ( list->next != list )
  574.         {
  575.             CLinkedList_Remove(list, list->next->content);
  576.         }
  577.         ODDisposePtr((ODPtr)list);
  578.         list = kODNULL;
  579.     }
  580. }
  581.  
  582.  
  583. void CLinkedList_Add(CLinkedList list, ODPtr content)
  584. {
  585.     CLink* link;
  586.     
  587.     link = (CLinkedList) ODNewPtrClear(sizeof(CLink), kODNULL);
  588.     
  589.     if ( link != kODNULL )
  590.     {
  591.         link->content = content;
  592.         link->prev = list;
  593.         link->next = list->next;
  594.         
  595.         list->next->prev = link;
  596.         list->next = link;
  597.     }
  598. }
  599.  
  600.  
  601. void
  602. CLinkedList_Remove(CLinkedList list, ODPtr content)
  603. {
  604.     CLink*    link;
  605.     CLink*    last;
  606.  
  607.     last = list;
  608.  
  609.     for (link = list->next ; link->content ; link = link->next)
  610.     {
  611.         if (link->content == content)
  612.         {
  613.             last->next = link->next;
  614.             link->next->prev = last;
  615.         
  616.             ODDisposePtr((ODPtr)link);
  617.             link = kODNULL;
  618.             return;
  619.         }
  620.         
  621.         last = link;
  622.     }
  623. }
  624.  
  625. CLink*
  626. CLinkedList_First(CLinkedList list)
  627. {
  628.     if (list)
  629.         return list->next;
  630.     else
  631.         return kODNULL;
  632. }
  633.  
  634. ODBoolean
  635. CLinkedList_Contains(CLinkedList list, ODPtr content)
  636. {
  637.     CLink *link;
  638.     for (link = list->next ; link->content ; link = link->next)
  639.     {
  640.         if (link->content == content)
  641.             return kODTrue;
  642.     }
  643.     
  644.     return kODFalse;
  645. }
  646.  
  647.  
  648. ODUShort
  649. CLinkedList_Count(CLinkedList list)
  650. {
  651.     ODUShort count = 0;
  652.     CLink *link;
  653.     for (link = list->next ; link->content ; link = link->next)
  654.         count++;
  655.     
  656.     return count;
  657. }
  658.  
  659.  
  660. //====================================================================
  661. // CLink
  662. //====================================================================
  663.  
  664. ODPtr
  665. CLink_Content(CLink* link)
  666. {
  667.     if (link)
  668.         return link->content;
  669.     else
  670.         return kODNULL;
  671. }
  672.  
  673. CLink*
  674. CLink_Next(CLink* link)
  675. {
  676.     if (link)
  677.         return link->next;
  678.     else
  679.         return kODNULL;
  680. }
  681.  
  682. //=========================================================================
  683. // CFrameProxy
  684. //=========================================================================
  685.  
  686. //==============================================================================
  687. #pragma mark    • CFrameProxy •
  688. //==============================================================================
  689.  
  690. //-------------------------------------------------------------------------
  691. // CFrameProxy_Create
  692. //-------------------------------------------------------------------------
  693.  
  694. CFrameProxy* CFrameProxy_Create()
  695. {
  696.     CFrameProxy* fp = kODNULL;
  697.     
  698.     fp = (CFrameProxy*) ODNewPtrClear(sizeof(CFrameProxy), kODNULL);
  699.  
  700.     if ( fp != kODNULL )
  701.     {
  702.         fp->fFrame        = kODNULL;
  703.         fp->fID            = kODNULLID;
  704.         fp->fDraft        = kODNULL;
  705.     }
  706.     
  707.     return fp;
  708. }
  709.  
  710. //-------------------------------------------------------------------------
  711. // CFrameProxy_Delete
  712. //-------------------------------------------------------------------------
  713.  
  714. void CFrameProxy_Delete(CFrameProxy** fp, Environment* ev)
  715. {
  716.     if ( *fp )
  717.     {
  718.         ODSafeReleaseObject((*fp)->fFrame);
  719.         ODDisposePtr((ODPtr)(*fp));
  720.         *fp = kODNULL;
  721.     }
  722. }
  723.  
  724. //-------------------------------------------------------------------------
  725. // CFrameProxy_InitFrameProxyDraft
  726. //-------------------------------------------------------------------------
  727. void CFrameProxy_InitFrameProxyWithID(CFrameProxy* fp, ODID frameID, ODDraft* draft)
  728. {
  729.     fp->fFrame = kODNULL;
  730.     fp->fID = frameID;
  731.     fp->fDraft = draft;
  732. }
  733.  
  734. //-------------------------------------------------------------------------
  735. // CFrameProxy_InitFrameProxyFrame
  736. //-------------------------------------------------------------------------
  737. void CFrameProxy_InitFrameProxyWithFrame(CFrameProxy* fp, Environment* ev, ODFrame* frame)
  738. {
  739.     CFrameProxy_SetFrame(fp, ev,frame);
  740. }
  741.  
  742. //-------------------------------------------------------------------------
  743. // CFrameProxy_Purge
  744. //-------------------------------------------------------------------------
  745. void CFrameProxy_Purge(CFrameProxy* fp, Environment* ev)
  746. {
  747.     if ( fp->fFrame )
  748.     {
  749.         fp->fID = ODFrame_GetID(fp->fFrame, ev);
  750.         ODReleaseObject(ev, fp->fFrame);
  751.     }
  752. }
  753.  
  754. //-------------------------------------------------------------------------
  755. // CFrameProxy_GetFrame
  756. //-------------------------------------------------------------------------
  757. ODFrame* CFrameProxy_GetFrame(CFrameProxy* fp, Environment* ev)
  758. {
  759.     ODFrame* frame = kODNULL;
  760.     ODVolatile( frame );
  761.     
  762.     if ( fp->fFrame == kODNULL )
  763.     {
  764.         TRY
  765.             ODFrame* frame = ODDraft_AcquireFrame(fp->fDraft, ev, fp->fID);
  766.             CHECK_ENV(ev);
  767.             
  768.             CFrameProxy_SetFrame(fp, ev, frame);
  769.             CHECK_ENV(ev);
  770.             
  771.             ODReleaseObject(ev, frame);
  772.         CATCH_ALL
  773.             ODSafeReleaseObject(frame);
  774.             fp->fFrame = kODNULL;
  775.             fp->fID = kODNULLID;
  776.         ENDTRY
  777.     }
  778.     return fp->fFrame;
  779. }
  780.  
  781. //-------------------------------------------------------------------------
  782. // CFrameProxy_SetFrame
  783. //-------------------------------------------------------------------------
  784. void CFrameProxy_SetFrame(CFrameProxy* fp, Environment* ev, ODFrame* frame)
  785. {
  786.     ODID id = kODNULLID;
  787.     ODDraft* draft = kODNULL;
  788.     ODPart* tPart = kODNULL;
  789.     
  790.     TRY
  791.         // Using the temp object will cleanup the incoming
  792.         // frame's refcount if something goes wrong.
  793.         ODFrame_Acquire(frame, ev);
  794.         CHECK_ENV(ev);
  795.         
  796.         // Perform all the operations that can fail, first.
  797.         tPart = ODFrame_AcquirePart(frame, ev);
  798.         CHECK_ENV(ev);
  799.         
  800.         id = ODFrame_GetID(frame, ev);
  801.         CHECK_ENV(ev);
  802.         
  803.         draft = ODGetDraftFromPart(ev, tPart);
  804.         CHECK_ENV(ev);
  805.         
  806.         ODReleaseObject(ev, fp->fFrame);
  807.         CHECK_ENV(ev);
  808.     
  809.         // If all went well, set the proxy fields.
  810.         fp->fFrame = frame;
  811.         fp->fID = id;
  812.         fp->fDraft = draft;
  813.     
  814.         ODReleaseObject(ev, tPart);
  815.     CATCH_ALL
  816.         ODSafeReleaseObject(tPart);
  817.     ENDTRY
  818. }
  819.  
  820. //-------------------------------------------------------------------------
  821. // CFrameProxy_FrameIsLoaded
  822. //-------------------------------------------------------------------------
  823. ODBoolean CFrameProxy_FrameIsLoaded(CFrameProxy* fp, Environment* ev)
  824. {
  825.     ODBoolean loaded = (fp->fFrame != kODNULL ||
  826.                         ODDraft_IsValidID(fp->fDraft, ev, fp->fID)); 
  827.     return loaded;
  828. }
  829.  
  830. //-------------------------------------------------------------------------
  831. // CFrameProxy_GetID
  832. //-------------------------------------------------------------------------
  833. ODID CFrameProxy_GetID(CFrameProxy* fp )
  834. {
  835.     return fp->fID;
  836. }
  837.  
  838. //-------------------------------------------------------------------------
  839. // CFrameProxy_GetDraft
  840. //-------------------------------------------------------------------------
  841. ODDraft* CFrameProxy_GetDraft(CFrameProxy* fp )
  842. {
  843.     return fp->fDraft;
  844. }
  845.     
  846. //=========================================================================
  847. // CFrameInfo
  848. //=========================================================================
  849.  
  850. //==============================================================================
  851. #pragma mark    • CFrameInfo •
  852. //==============================================================================
  853.  
  854. //-------------------------------------------------------------------------
  855. // CFrameInfo_Create
  856. //-------------------------------------------------------------------------
  857.  
  858.  
  859. CFrameInfo* CFrameInfo_Create(ODSession* session)
  860. {
  861.     CFrameInfo* fi;
  862.     
  863.     fi = (CFrameInfo*) ODNewPtrClear(sizeof(CFrameInfo), kODNULL);
  864.  
  865.     if ( fi != kODNULL )
  866.     {
  867.         fi->fSession             = session;
  868.         fi->fFrameActive        = kODFalse;
  869.         fi->fFrameReactivate    = kODFalse;
  870.         fi->fShouldDisposeWindow    = kODFalse;
  871.         fi->fActiveFacet        = kODNULL;
  872.         fi->fSourceFrame        = kODNULL;
  873.         fi->fDependentFrame        = kODNULL;
  874.         fi->fPartWindowID         = kODNULLID;
  875.     }
  876.     
  877.     return fi;
  878. }
  879.  
  880. //-------------------------------------------------------------------------
  881. // CFrameInfo_Delete
  882. //-------------------------------------------------------------------------
  883.  
  884. void CFrameInfo_Delete(CFrameInfo** fi, Environment* ev)
  885. {
  886.     CFrameProxy_Delete( &((*fi)->fSourceFrame), ev );
  887.     CFrameProxy_Delete( &((*fi)->fDependentFrame), ev );
  888.         
  889.     ODDisposePtr((ODPtr)(*fi));
  890.     *fi = kODNULL;
  891. }
  892.  
  893. //-------------------------------------------------------------------------
  894. // CFrameInfo_Externalize
  895. //-------------------------------------------------------------------------
  896.  
  897. void CFrameInfo_Externalize(CFrameInfo* fi, Environment* ev, ODStorageUnitView* storageUnitView)
  898. {
  899.     // This method assumes that OpenDoc has passed us a storageUnitView
  900.     // that is focused to a property, but no particular value.
  901.     
  902.     ODStorageUnit* storageUnit = ODStorageUnitView_GetStorageUnit(storageUnitView, ev);
  903.  
  904.     CFrameInfo_CleanseFrameInfoProperty(fi, ev, storageUnit);
  905.     CFrameInfo_ExternalizeFrameInfo(fi, ev, storageUnit, kODNULLKey, kODNULL);
  906. }
  907.  
  908. //-------------------------------------------------------------------------
  909. // CFrameInfo::CleanseFrameInfoProperty
  910. //-------------------------------------------------------------------------
  911.  
  912. void CFrameInfo_CleanseFrameInfoProperty(CFrameInfo* fi, Environment* ev, ODStorageUnit* storageUnit)
  913. {
  914.     ODULong        numValues;
  915.     ODULong        index;
  916.     ODValueType    value;
  917.         
  918.     numValues = ODStorageUnit_CountValues(storageUnit, ev);
  919.     
  920.     for (index = numValues; index >= 1; index--)
  921.     {
  922.         // Index from 1 to n through the values.
  923.         ODStorageUnit_Focus(storageUnit, ev, kODNULL, kODPosSame, 
  924.                                 kODNULL, index, kODPosUndefined);
  925.  
  926.         // Get the ISO type name for the value. The storage unit
  927.         // will allocate memory for the returned ISOStr.
  928.         value = ODStorageUnit_GetType(storageUnit, ev);
  929.         
  930.         // If the value type is not one we support, remove it.
  931.         if ( ODISOStrCompare(value, kSamplePartInfo) != 0 )
  932.             ODStorageUnit_Remove(storageUnit, ev);
  933.             
  934.         ODDisposePtr(value);
  935.     }
  936. }
  937.  
  938. //-------------------------------------------------------------------------
  939. // CFrameInfo::ExternalizeFrameInfo
  940. //-------------------------------------------------------------------------
  941.  
  942. void CFrameInfo_ExternalizeFrameInfo(CFrameInfo* fi, Environment* ev,
  943.                                         ODStorageUnit* storageUnit,
  944.                                         ODDraftKey key,
  945.                                         ODFrame* scopeFrame)
  946. {
  947.     // This method behaves much the same way as the
  948.     // SamplePart::ExternalizeStateInfo method.
  949.     
  950.     if ( ODStorageUnit_Exists(storageUnit, ev, kODNULL, kSamplePartInfo, 0) )
  951.     {
  952.         // Persistent object references are stored in a side table, rather than
  953.         // in the property/value stream. Thus, deleting the contents of a value
  954.         // will not "delete" the references previously written to that value. To
  955.         // completely "delete" all references written to the value, we must
  956.         // remove the value and add it back.
  957.  
  958.         ODStorageUnit_Focus(storageUnit, ev, kODNULL, kODPosSame, kSamplePartInfo, 0 , kODPosUndefined);
  959.         ODStorageUnit_Remove(storageUnit, ev);
  960.     }
  961.     
  962.     // Add a value to write the data into.
  963.     ODStorageUnit_AddValue(storageUnit, ev, kSamplePartInfo);
  964.     
  965.     // Write a weak reference to our source frame.
  966.     {
  967.         ODStorageUnitRef weakRef = {0,0,0,0};
  968.  
  969.         if ( fi->fSourceFrame )
  970.         {
  971.             ODID                frameID;
  972.             ODID                scopeFrameID;
  973.             ODDraft*            fromDraft;
  974.     
  975.             frameID = CFrameProxy_GetID(fi->fSourceFrame);
  976.             scopeFrameID = ( scopeFrame ? ODFrame_GetID(scopeFrame, ev) : 0 );
  977.             fromDraft = CFrameProxy_GetDraft(fi->fSourceFrame);
  978.     
  979.             // If a draft key exists, then we are being cloned to another draft.
  980.             // We must "weak" clone our display frame and reference the cloned
  981.             // frame. The part re-uses the frameID variable so there aren't two
  982.             // different GetWeakStorageUnitRef calls.
  983.             if ( key )
  984.                 frameID = ODDraft_WeakClone(fromDraft, ev, key, frameID,
  985.                                                 kODNULLID, scopeFrameID);
  986.             
  987.             // Write out weak references to each of the part's display frames.
  988.             ODStorageUnit_GetWeakStorageUnitRef(storageUnit, ev, frameID, weakRef);
  989.         }
  990.         StorageUnitSetValue_C(storageUnit, ev, sizeof(ODStorageUnitRef), (ODPtr)&weakRef);
  991.     }
  992.  
  993.     // Write a weak reference to our dependent frame.
  994.     {
  995.         ODStorageUnitRef weakRef = {0,0,0,0};
  996.  
  997.         if ( fi->fDependentFrame )
  998.         {
  999.             ODID                frameID;
  1000.             ODID                scopeFrameID;
  1001.             ODDraft*            fromDraft;
  1002.     
  1003.             frameID = CFrameProxy_GetID(fi->fDependentFrame);
  1004.             scopeFrameID = ( scopeFrame ? ODFrame_GetID(scopeFrame, ev) : 0 );
  1005.             fromDraft = CFrameProxy_GetDraft(fi->fDependentFrame);
  1006.     
  1007.             // If a draft key exists, then we are being cloned to another draft.
  1008.             // We must "weak" clone our display frame and reference the cloned
  1009.             // frame. The part re-uses the frameID variable so there aren't two
  1010.             // different GetWeakStorageUnitRef calls.
  1011.             if ( key )
  1012.                 frameID = ODDraft_WeakClone(fromDraft, ev, key, frameID,
  1013.                                                 kODNULLID, scopeFrameID);
  1014.             
  1015.             // Write out weak references to each of the part's display frames.
  1016.             ODStorageUnit_GetWeakStorageUnitRef(storageUnit, ev, frameID, weakRef);
  1017.         }
  1018.         StorageUnitSetValue_C(storageUnit, ev, sizeof(ODStorageUnitRef), (ODPtr)&weakRef);
  1019.     }
  1020. }
  1021.  
  1022. //-------------------------------------------------------------------------
  1023. // CFrameInfo::CloneInto
  1024. //-------------------------------------------------------------------------
  1025.  
  1026. void CFrameInfo_CloneInto(CFrameInfo* fi, Environment *ev, ODDraftKey key,
  1027.                             ODStorageUnitView* storageUnitView,
  1028.                             ODFrame* scopeFrame)
  1029. {
  1030.     // This method assumes that OpenDoc has passed us a storageUnitView
  1031.     // that is focused to a property, but no particular value.
  1032.     
  1033.     ODStorageUnit* storageUnit =
  1034.                     ODStorageUnitView_GetStorageUnit(storageUnitView, ev);
  1035.  
  1036.     if ( ODStorageUnit_Exists(storageUnit, ev, kODNULL, kSamplePartInfo, 0)
  1037.             == kODFalse )
  1038.     {
  1039.         CFrameInfo_ExternalizeFrameInfo(fi, ev, storageUnit, key, scopeFrame);
  1040.     }
  1041. }
  1042.  
  1043. //-------------------------------------------------------------------------
  1044. // CFrameInfo::InitFromStorage
  1045. //-------------------------------------------------------------------------
  1046.  
  1047. void CFrameInfo_InitFromStorage(CFrameInfo* fi, Environment* ev,
  1048.                                     ODStorageUnitView* storageUnitView)
  1049. {
  1050.     // This method assumes that OpenDoc has passed us a storageUnitView
  1051.     // that is focused to a property, but no particular value.
  1052.     
  1053.     ODULong size;
  1054.     ODStorageUnitRef weakRef = {0,0,0,0};
  1055.     ODStorageUnitRef weakRef2 = {0,0,0,0};
  1056.     CFrameProxy* proxy = kODNULL;
  1057.     CFrameProxy* proxy2 = kODNULL;
  1058.     ODID frameID;
  1059.      ODStorageUnit* storageUnit =
  1060.                         ODStorageUnitView_GetStorageUnit(storageUnitView, ev);
  1061.  
  1062.     if ( ODStorageUnit_Exists(storageUnit, ev, kODNULL, kSamplePartInfo, 0) )
  1063.     {
  1064.         TRY
  1065.             ODStorageUnit_Focus(storageUnit, ev, kODNULL, kODPosSame,
  1066.                                         kSamplePartInfo, 0 , kODPosUndefined);
  1067.             CHECK_ENV(ev);
  1068.     
  1069.             size = ODStorageUnit_GetSize(storageUnit, ev);
  1070.             CHECK_ENV(ev);
  1071.         
  1072.             StorageUnitGetValue_C(storageUnit, ev, sizeof(ODStorageUnitRef),
  1073.                                 (ODPtr)&weakRef);
  1074.             CHECK_ENV(ev);
  1075.                 
  1076.             if ( ODStorageUnit_IsValidStorageUnitRef(storageUnit, ev, weakRef) )
  1077.             {
  1078.                 // Convert the reference into a runtime id.
  1079.                 frameID = ODStorageUnit_GetIDFromStorageUnitRef(storageUnit, ev, weakRef);
  1080.                 CHECK_ENV(ev);
  1081.  
  1082.                 // Create a proxy class to support the lazy internalization.
  1083.                 proxy = CFrameProxy_Create();
  1084.                 CFrameProxy_InitFrameProxyWithID(proxy, frameID, ODGetDraftFromSU(ev,storageUnit));
  1085.                 
  1086.                 // Store the proxy source frame.
  1087.                 fi->fSourceFrame = proxy;
  1088.             }
  1089.             else
  1090.             {
  1091.                 fi->fSourceFrame = kODNULL;
  1092.             }
  1093.             CHECK_ENV(ev);
  1094.  
  1095.             
  1096.         CATCH_ALL
  1097.             CFrameProxy_Delete(&(fi->fSourceFrame), ev);
  1098.         ENDTRY
  1099.  
  1100.         TRY
  1101.             StorageUnitGetValue_C(storageUnit, ev, sizeof(ODStorageUnitRef),
  1102.                                 (ODPtr)&weakRef);
  1103.             CHECK_ENV(ev);
  1104.             
  1105.             if ( ODStorageUnit_IsValidStorageUnitRef(storageUnit, ev, weakRef) )
  1106.             {
  1107.                 // Convert the reference into a runtime id.
  1108.                 frameID = ODStorageUnit_GetIDFromStorageUnitRef(storageUnit, ev, weakRef);
  1109.                 CHECK_ENV(ev);
  1110.  
  1111.                 // Create a proxy class to support the lazy internalization.
  1112.                 proxy2 = CFrameProxy_Create();
  1113.                 CFrameProxy_InitFrameProxyWithID(proxy, frameID, ODGetDraftFromSU(ev,storageUnit));
  1114.  
  1115.                 // Store the proxy dependent frame.
  1116.                 fi->fDependentFrame = proxy;
  1117.             }
  1118.             else
  1119.             {
  1120.                 fi->fDependentFrame = kODNULL;
  1121.             }
  1122.             CHECK_ENV(ev);
  1123.             
  1124.         CATCH_ALL
  1125.             CFrameProxy_Delete(&(fi->fDependentFrame), ev);
  1126.         ENDTRY
  1127.     }
  1128. }
  1129.  
  1130.  
  1131. //-------------------------------------------------------------------------
  1132. // CFrameInfo_SetSourceFrame
  1133. //-------------------------------------------------------------------------
  1134.  
  1135. void CFrameInfo_SetSourceFrame(CFrameInfo* fi, Environment* ev, ODFrame* frame)
  1136. {
  1137.     if ( frame != kODNULL )
  1138.     {
  1139.         // Create a proxy class to support the lazy internalization.
  1140.         CFrameProxy* proxy = CFrameProxy_Create();
  1141.         CFrameProxy_InitFrameProxyWithFrame(proxy, ev, frame);
  1142.         
  1143.         // Store the proxy source frame after clearing the old one.
  1144.         CFrameProxy_Delete(&(fi->fSourceFrame), ev);
  1145.         fi->fSourceFrame = proxy;
  1146.     }
  1147. }
  1148.  
  1149.  
  1150. //-------------------------------------------------------------------------
  1151. // CFrameInfo_ReleaseSourceFrame
  1152. //-------------------------------------------------------------------------
  1153.  
  1154. void CFrameInfo_ReleaseSourceFrame(CFrameInfo* fi, Environment* ev)
  1155. {
  1156.     CFrameProxy_Delete(&(fi->fSourceFrame), ev);
  1157. }
  1158.  
  1159.  
  1160. //-------------------------------------------------------------------------
  1161. // CFrameInfo_IsFrameActive
  1162. //-------------------------------------------------------------------------
  1163.  
  1164. ODBoolean CFrameInfo_IsFrameActive(CFrameInfo* fi)
  1165. {
  1166.     return fi->fFrameActive;
  1167. }
  1168.  
  1169.  
  1170. //-------------------------------------------------------------------------
  1171. // CFrameInfo_SetFrameActive
  1172. //-------------------------------------------------------------------------
  1173.  
  1174. void CFrameInfo_SetFrameActive(CFrameInfo* fi, ODBoolean active)
  1175. {
  1176.     fi->fFrameActive = active;
  1177. }
  1178.  
  1179.  
  1180. //-------------------------------------------------------------------------
  1181. // CFrameInfo_FrameNeedsReactivating
  1182. //-------------------------------------------------------------------------
  1183.  
  1184. ODBoolean CFrameInfo_FrameNeedsReactivating(CFrameInfo* fi)
  1185. {
  1186.     return fi->fFrameReactivate;
  1187. }
  1188.  
  1189.  
  1190. //-------------------------------------------------------------------------
  1191. // CFrameInfo_SetFrameReactivate
  1192. //-------------------------------------------------------------------------
  1193.  
  1194. void CFrameInfo_SetFrameReactivate(CFrameInfo* fi, ODBoolean reactivate)
  1195. {
  1196.     fi->fFrameReactivate = reactivate;
  1197. }
  1198.  
  1199.  
  1200. //-------------------------------------------------------------------------
  1201. // CFrameInfo_SetActiveFacet
  1202. //-------------------------------------------------------------------------
  1203.  
  1204. void CFrameInfo_SetActiveFacet(CFrameInfo* fi, ODFacet* facet)
  1205. {
  1206.     fi->fActiveFacet = facet;
  1207. }
  1208.  
  1209.  
  1210. //-------------------------------------------------------------------------
  1211. // CFrameInfo_SetActiveFacet
  1212. //-------------------------------------------------------------------------
  1213.  
  1214. ODFacet* CFrameInfo_GetActiveFacet(CFrameInfo* fi)
  1215. {
  1216.     return fi->fActiveFacet;
  1217. }
  1218.  
  1219.  
  1220. //-------------------------------------------------------------------------
  1221. // CFrameInfo_GetSourceFrame
  1222. //-------------------------------------------------------------------------
  1223.  
  1224. ODFrame* CFrameInfo_GetSourceFrame(CFrameInfo* fi, Environment* ev)
  1225. {
  1226.     return CFrameProxy_GetFrame(fi->fSourceFrame, ev);
  1227. }
  1228.  
  1229.  
  1230. //-------------------------------------------------------------------------
  1231. // CFrameInfo_HasSourceFrame
  1232. //-------------------------------------------------------------------------
  1233.  
  1234. ODBoolean CFrameInfo_HasSourceFrame(CFrameInfo* fi)
  1235. {
  1236.     return (fi->fSourceFrame != kODNULL);
  1237. }
  1238.  
  1239.  
  1240. //-------------------------------------------------------------------------
  1241. // CFrameInfo_AcquirePartWindow
  1242. //-------------------------------------------------------------------------
  1243.  
  1244. ODWindow* CFrameInfo_AcquirePartWindow(CFrameInfo* fi, Environment* ev)
  1245. {
  1246.     ODWindow*        window = kODNULL;
  1247.     ODWindowState*    windowState;
  1248.     
  1249.     if ( fi->fPartWindowID )
  1250.     {
  1251.         windowState = ODSession_GetWindowState(fi->fSession, ev);
  1252.         window = ODWindowState_AcquireWindow(windowState, ev, fi->fPartWindowID);
  1253.         if ( !window ) fi->fPartWindowID = kODNULLID;
  1254.     }
  1255.     
  1256.     return window;
  1257. }
  1258.  
  1259.  
  1260. //-------------------------------------------------------------------------
  1261. // CFrameInfo_SetPartWindow
  1262. //-------------------------------------------------------------------------
  1263.  
  1264. void CFrameInfo_SetPartWindow(CFrameInfo* fi, Environment* ev, ODWindow* window)
  1265. {
  1266.     fi->fPartWindowID = window ? ODWindow_GetID(window, ev) : kODNULLID;
  1267. }
  1268.  
  1269.  
  1270. //-------------------------------------------------------------------------
  1271. // CFrameInfo_SetDependentFrame
  1272. //-------------------------------------------------------------------------
  1273.  
  1274. void CFrameInfo_SetDependentFrame(CFrameInfo* fi, Environment* ev, ODFrame* frame)
  1275. {
  1276.     if ( frame != kODNULL )
  1277.     {
  1278.         // Create a proxy class to support the lazy internalization.
  1279.         CFrameProxy* proxy = CFrameProxy_Create();
  1280.         CFrameProxy_InitFrameProxyWithFrame(proxy, ev, frame);
  1281.         
  1282.         // Store the proxy dependent frame after clearing the old one.
  1283.         CFrameProxy_Delete(&(fi->fDependentFrame), ev);
  1284.         fi->fDependentFrame = proxy;
  1285.     }
  1286. }
  1287.  
  1288. //-------------------------------------------------------------------------
  1289. // CFrameInfo_GetDependentFrame
  1290. //-------------------------------------------------------------------------
  1291.  
  1292. ODFrame* CFrameInfo_GetDependentFrame(CFrameInfo* fi, Environment* ev)
  1293. {
  1294.     return (CFrameProxy_GetFrame(fi->fDependentFrame, ev));
  1295. }
  1296.  
  1297. //-------------------------------------------------------------------------
  1298. // CFrameInfo_HasDependentFrame
  1299. //-------------------------------------------------------------------------
  1300.  
  1301. ODBoolean CFrameInfo_HasDependentFrame(CFrameInfo* fi)
  1302. {
  1303.     return (fi->fDependentFrame != kODNULL);
  1304. }
  1305.  
  1306. //-------------------------------------------------------------------------
  1307. // CFrameInfo_ReleaseDependentFrame
  1308. //-------------------------------------------------------------------------
  1309.  
  1310. void CFrameInfo_ReleaseDependentFrame(CFrameInfo* fi, Environment* ev)
  1311. {
  1312.     CFrameProxy_Delete(&(fi->fDependentFrame), ev);
  1313. }
  1314.  
  1315. //-------------------------------------------------------------------------
  1316. // CFrameInfo_SetShouldDisposeWindow
  1317. //-------------------------------------------------------------------------
  1318.  
  1319. void CFrameInfo_SetShouldDisposeWindow(CFrameInfo* fi, ODBoolean should)
  1320. {
  1321.     fi->fShouldDisposeWindow = should;
  1322. }
  1323.  
  1324. //-------------------------------------------------------------------------
  1325. // CFrameInfo_ShouldDisposeWindow
  1326. //-------------------------------------------------------------------------
  1327.  
  1328. ODBoolean CFrameInfo_ShouldDisposeWindow(CFrameInfo* fi)
  1329. {
  1330.     return fi->fShouldDisposeWindow;
  1331. }
  1332.  
  1333.